scroll to cursor on grab focus, unless it's caused by button click, #59708
authorHavoc Pennington <hp@redhat.com>
Tue, 23 Oct 2001 16:07:05 +0000 (16:07 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Tue, 23 Oct 2001 16:07:05 +0000 (16:07 +0000)
2001-10-23  Havoc Pennington  <hp@redhat.com>

* gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
on grab focus, unless it's caused by button click, #59708

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextview.c
gtk/gtktextview.h

index 11af575157263461830b16f090771362b24629d7..7f6cee8625ac846d4d60712817a6933902d533b3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
+       on grab focus, unless it's caused by button click, #59708
+
 Tue Oct 23 11:53:00 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS.
index 11af575157263461830b16f090771362b24629d7..7f6cee8625ac846d4d60712817a6933902d533b3 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
+       on grab focus, unless it's caused by button click, #59708
+
 Tue Oct 23 11:53:00 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS.
index 11af575157263461830b16f090771362b24629d7..7f6cee8625ac846d4d60712817a6933902d533b3 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
+       on grab focus, unless it's caused by button click, #59708
+
 Tue Oct 23 11:53:00 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS.
index 11af575157263461830b16f090771362b24629d7..7f6cee8625ac846d4d60712817a6933902d533b3 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
+       on grab focus, unless it's caused by button click, #59708
+
 Tue Oct 23 11:53:00 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS.
index 11af575157263461830b16f090771362b24629d7..7f6cee8625ac846d4d60712817a6933902d533b3 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
+       on grab focus, unless it's caused by button click, #59708
+
 Tue Oct 23 11:53:00 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS.
index 11af575157263461830b16f090771362b24629d7..7f6cee8625ac846d4d60712817a6933902d533b3 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
+       on grab focus, unless it's caused by button click, #59708
+
 Tue Oct 23 11:53:00 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS.
index 11af575157263461830b16f090771362b24629d7..7f6cee8625ac846d4d60712817a6933902d533b3 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-23  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextview.c (gtk_text_view_grab_focus): scroll to cursor
+       on grab focus, unless it's caused by button click, #59708
+
 Tue Oct 23 11:53:00 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS.
index 5a5fa96ee5a3efbf96c741c4199f2069d0dd659c..968abde9f2b5400e873c831161226c249dba41bb 100644 (file)
@@ -172,6 +172,7 @@ static gint gtk_text_view_motion_event         (GtkWidget        *widget,
 static gint gtk_text_view_expose_event         (GtkWidget        *widget,
                                                 GdkEventExpose   *expose);
 static void gtk_text_view_draw_focus           (GtkWidget        *widget);
+static void gtk_text_view_grab_focus           (GtkWidget        *widget);
 
 /* Source side drag signals */
 static void gtk_text_view_drag_begin       (GtkWidget        *widget,
@@ -3272,7 +3273,9 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
 
   text_view = GTK_TEXT_VIEW (widget);
 
+  text_view->disable_scroll_on_focus = TRUE;
   gtk_widget_grab_focus (widget);
+  text_view->disable_scroll_on_focus = FALSE;
 
   if (event->window != text_view->text_window->bin_window)
     {
@@ -3647,6 +3650,21 @@ gtk_text_view_draw_focus (GtkWidget *widget)
     }
 }
 
+static void
+gtk_text_view_grab_focus (GtkWidget *widget)
+{
+  GtkTextView *text_view;
+
+  text_view = GTK_TEXT_VIEW (widget);
+  
+  GTK_WIDGET_CLASS (parent_class)->grab_focus (widget);
+
+  if (!text_view->disable_scroll_on_focus)
+    gtk_text_view_scroll_mark_onscreen (text_view,
+                                        gtk_text_buffer_get_mark (get_buffer (text_view),
+                                                                  "insert"));
+}
+
 /*
  * Container
  */
index 430c53a9e436f4d4c1406ba6a2d55b8699968a35..e296c4621d4ab5a088050e270a646bfa62fff26e 100644 (file)
@@ -92,6 +92,9 @@ struct _GtkTextView
   guint  need_im_reset : 1;    /* If we have reset the IM since the last character entered */
   /* just selected a word or line via double/triple click */
   guint just_selected_element : 1;
+
+  /* disable scrolling to cursor on focus */
+  guint disable_scroll_on_focus : 1;
   
   /* debug flag - means that we've validated onscreen since the
    * last "invalidate" signal from the layout